<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>创建课程-课程详情</title>
	<link rel="stylesheet" href="css/left.css">
	<link rel="stylesheet" href="css/detail.css">
</head>
<body>
<!-- 加载头部信息 -->
<?php
	include_once("header.php");
?>

<!-- 中间内容 -->
<div class="content clearfloat">
	<!-- 左边内容 -->
	<div class="left_content">
		<ul class="left_nav" id="left_ul">
			<li><a href="notice.php" class="li_a">
				<span class="text">
					<?php echo "<img src='images/notice.png' alt='图片' class='left_img1'";?>&nbsp;
					<span>动&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态</span>
				</span>
				<canvas id="canvas_index1" width="18" height="48"></canvas>	
			</a></li>
			<li class="active_nav"><a href="addcourse.php" class="li_a">
				<span class="text">
					<?php echo "<img src='images/course.png' alt='图片' class='left_img2'";?>
					<span>创建课程</span>
				</span>
				<canvas id="canvas_index2" width="18" height="48"></canvas>
			</a></li>
			<li><a href="mycourse.php" class="li_a">
				<span class="text">
					<?php echo "<img src='images/mycourse.png' alt='图片' class='left_img3'";?>
					<span>我的课程</span>
				</span>
				<canvas id="canvas_index3" width="18" height="48"></canvas>
			</a></li>
			<li><a href="checkbook.php" class="li_a">
				<span class="text">
					<?php echo "<img src='images/correct.png' alt='图片' class='left_img4'";?>
					<span>批改作业</span>
				</span>
				<canvas id="canvas_index4" width="18" height="48"></canvas>
			</a></li>
			<li><a href="per_setup.php" class="li_a">
				<span class="text">
					<?php echo "<img src='images/setup.png' alt='图片' class='left_img6'";?>
					<span>个人设置</span>
				</span>
				<canvas id="canvas_index6" width="18" height="48"></canvas>
			</a></li>
		</ul>
	</div>

	<!-- 右边内容 -->
	<div class="center_content">
		<ul id="nav">
			<li class="active li_a1"><a href="#" class="clearfloat a_prohibit">
				<span class="text">
					<span class="number">01</span>
					<span>基本信息</span>
				</span>
				<canvas id="canvas1" width="14" height="34"></canvas>
			</a></li>
			<li class="active li_a2"><a href="#" class="clearfloat a_prohibit">
				<canvas id="canvas2" width="14" height="34"></canvas>
				<span class="text">
					<span class="number">02</span>
					<span>课程详情</span>
				</span>
				<canvas id="canvas3" width="14" height="34"></canvas>
			</a></li>
			<li class="li_a3"><a href="#" class="clearfloat a_prohibit">
				<canvas id="canvas4" width="14" height="34"></canvas>
				<span class="text">
					<span class="number">03</span>
					<span>创建完成</span>
				</span>
			</a></li>
		</ul>
		
		<div class="center_info">
			<div class="content_title">
				<h4>数据结构</h4>
				<hr>
			</div>

			<div class="course_form">
				<form action="" method="post" class="select_img" enctype="multipart/form-data">
					<label for="btn_img" class="btn_img">封面图片:</label>
					<div class="touxiang">
						<div id="image-holder">
							<?php echo "<img src='images/no_image.jpg' alt='图片' id='file_img'>";?>
						</div>
						<a href="javascript:void(0);" class="input file_btn">
							选择封面<input type="file" id="upfile" name="upfile">
						</a>&nbsp;&nbsp;&nbsp;&nbsp;
					</div>	

					<div class="course_select">
					<label for="course_credit" class="course_credit">课程学分:</label> 
					<select name="course_credit" id="course_credit">
						<option value="1">1</option>
						<option value="2">2</option>
						<option value="3">3</option>
						<option value="4">4</option>
						<option value="5">5</option>
						<option value="6">6</option>
						<option value="7">7</option>
						<option value="8">8</option>
						<option value="9">9</option>
						<option value="10" selected="selected">10</option>
					</select><br/>

					<label for="course_period" class="course_period">课程学时:</label>
					<select name="course_period" id="course_period">
						<option value="100">100</option>
						<option value="110">110</option>
						<option value="120">120</option>
						<option value="130">130</option>
						<option value="140">140</option>
						<option value="150" selected="selected">150</option>
						<option value="160">160</option>
						<option value="170">170</option>
						<option value="180">180</option>
						<option value="190">190</option>
					</select><br/>

					<label for="course_type" class="course_type">课程类型:</label>
					<select name="course_type" id="course_type">
						<option value="专业基础课" selected="selected">专业基础课</option>
						<option value="专业选修课">专业选修课</option>
						<option value="公共选修课">公共选修课</option>
					</select><br/>
					</div>
					<label class="course_details">课程简介:</label>
					<div class="course_iframe">
						<?php include_once("font_icon.php");?>
						<iframe src="iframe_infos.php" frameborder="0" width="815" height="233"></iframe>
					</div>
				
					<input type="submit" name="submit_down" value="点击下一步" class="btn active_btn">
					<input type="submit" name="submit" value="取消" class="btn">
				</form>
			</div>
		</div>
	</div>
	
	<!-- 右侧栏 -->
	<?php
		include_once("right_content.php");
	?>
</div>

<!-- 加载左边导航的样式 -->
<?php
	include_once("nav_style.php");
?>

<?php
echo <<<canvas
<script>
    //创建绘图容器
    var canvas1 = document.getElementById("canvas1");
    var canvas2 = document.getElementById("canvas2");
    var canvas3 = document.getElementById("canvas3");
    var canvas4 = document.getElementById("canvas4");
   
   	function canvas_triangle1(canvas) {
		var context = canvas.getContext("2d");

		//状态设置
		context.moveTo(0, 0);
    	context.lineTo(0, 34);
   		context.lineTo(14, 18);
    	context.lineTo(0, 0);
		context.fillStyle = "#049fc7";  //设置填充颜色

		//状态绘画
		context.fill();
   	}

    function canvas_triangle2(canvas) {
		var context = canvas.getContext("2d");

		//状态设置
		context.moveTo(0, 0);
    	context.lineTo(0, 34);
   		context.lineTo(14, 18);
    	context.lineTo(0, 0);
		context.fillStyle = "#fff";  //设置填充颜色#fff

		//状态绘画
		context.fill(); 
    }
   
   	canvas_triangle1(canvas1);
 	canvas_triangle1(canvas3);
 	canvas_triangle2(canvas2);
 	canvas_triangle2(canvas4);
</script>

canvas;
?>

<?php 
if(isset($_COOKIE["tea_number"])) {
	$tea_number = $_COOKIE["tea_number"];

	if(isset($_POST["submit_down"]) && $_POST["submit_down"] == "点击下一步") {

		foreach($_FILES as $key => $value) {
			// echo "{$key}的值为:<br/>";
			foreach ($_FILES[$key] as $ke => $valu) {
				// echo "{$ke}: {$valu}<br/>";
			}
		}

		if(!empty($_FILES[$key]["name"])) {//判断是否选择了文件上传
			//指定上传文件路径以及名字
			$pathname = "./course/".$_FILES[$key]["name"];

			$course_img = "course/".$_FILES[$key]["name"];
			
			$result = move_uploaded_file($_FILES[$key]["tmp_name"], $pathname);					
		} 

		$course_credit = $_POST["course_credit"];
		$course_period = $_POST["course_period"];
		$course_type = $_POST["course_type"];
		$summary = $_POST["summary"];

		$updatesql = "update courses set course_img='$course_img',course_credit='$course_credit',
			course_period='$course_period',course_type='$course_type',course_summary='$summary'
			where tea_number='$tea_number'";
		
		include_once("database.php");

		@mysql_query($updatesql) or die("修改课程信息表失败：".mysql_error()."<br/>");

		echo "<script>";
		echo "{window.location='addcourse_finish.php';}";
		echo "</script>";
	}

	if(isset($_POST["submit"]) && $_POST["submit"] == "取消") {
		echo "<script>";
		echo "{window.location='addcourse.php';}";
		echo "</script>";
	}
}
?>

<script src="js/jquery-3.2.1.js"></script>
<script>
    $("#upfile").on('change', function () {
        if (typeof (FileReader) != "undefined") {

            var image_holder = $("#image-holder");
            image_holder.empty();

            var reader = new FileReader();
            reader.onload = function (e) {
                $("<img />", {
                    "src": e.target.result,
                    "class": "thumb-image"
                }).appendTo(image_holder);
            };
            image_holder.show();
            reader.readAsDataURL($(this)[0].files[0]);
        } else {
            alert("你的浏览器不支持FileReader.");
        }

    });
</script>

<!-- 加载底部信息 -->
<?php
	include_once("footer.php");
?>
</body>
</html>